package com.sunnada.edu.system.sysdict.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sunnada.edu.system.pub.dao.BaseDaoImpl;

@Repository
public class SysDictDaoImpl extends BaseDaoImpl implements SysDictDao {

	@Override
	public int getDictCots(HashMap<String, String> params) {
		List list = selectList("sysdict_sqlmap.getSysDictCots", params);
		if(list!=null&&list.size()>0){
			String cot = ((Map)list.get(0)).get("cot")+"";
			return Integer.valueOf(cot);
		}
		return 0;
	}

	@Override
	public List<?> findDicts(HashMap<String, String> params) {
		return selectList("sysdict_sqlmap.findSysDicts", params);
	}

	@Override
	public int dictDelete(HashMap<String, String> params) {
		return delete("sysdict_sqlmap.dictDelete", params);
	}

	@Override
	public int dictAdd(HashMap<String, String> params) {
		return insert("sysdict_sqlmap.dictAdd",params);
	}

	@Override
	public int dictUpdate(HashMap<String, String> params) {
		return update("sysdict_sqlmap.dictUpdate",params);
	}

	@Override
	public Map getDictByRecId(HashMap<String, String> params) {
		List list = selectList("sysdict_sqlmap.getSysDictByRecId", params);
		if(list!=null&&list.size()>0){
			return (Map)list.get(0);
		}
		return null;
	}	
	
	@Override
	public int getDictTypeCots(HashMap<String, String> params) {
		List list = selectList("sysdict_sqlmap.getDictTypeCots", params);
		if(list!=null&&list.size()>0){
			String cot = ((Map)list.get(0)).get("cot")+"";
			return Integer.valueOf(cot);
		}
		return 0;
	}

	@Override
	public List<?> findDictTypes(HashMap<String, String> params) {
		return selectList("sysdict_sqlmap.findDictTypes", params);
	}
	
	@Override
	public Map getDictTypeByRecId(HashMap<String, String> params) {
		List list = selectList("sysdict_sqlmap.getSysDictTypeByRecId", params);
		if(list!=null&&list.size()>0){
			return (Map)list.get(0);
		}
		return null;
	}
	
	@Override
	public int typeUpdateSave(HashMap<String, String> params) {
		return update("sysdict_sqlmap.typeUpdateSave",params);
	}
	
	@Override
	public int dictTypeDelete(HashMap<String, String> params) {
		return delete("sysdict_sqlmap.dictTypeDelete", params);
	}
}
